package Admin;

import javax.swing.ButtonModel;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.JTable;
import javax.swing.JScrollPane;
import javax.swing.table.DefaultTableModel;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.Vector;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JComboBox;
import javax.swing.JRadioButton;
import javax.swing.ButtonGroup;
import javax.swing.DefaultComboBoxModel;

import java.awt.Component;

import javax.swing.Box;
import javax.swing.JCheckBox;

import java.awt.Color;

import javax.swing.JTextArea;
import javax.swing.SwingConstants;

import java.awt.Font;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;

import javax.swing.JSeparator;

public class MemberPanel extends JPanel {
	private JPanel contentPane;
	private JTextField textField;
	private JButton btnNewButton;
	private JScrollPane scrollPane;
	private JTable table;
	ManageDTO dto;
	private JLabel lblNewLabel;
	private JLabel label;
	private JLabel label_1;
	private JLabel label_2;
	private JRadioButton radioButton;
	private JRadioButton radioButton_1;
	private JRadioButton radioButton_2;
	private final ButtonGroup buttonGroup = new ButtonGroup();
	private JCheckBox chckbxNewCheckBox;
	private JCheckBox checkBox;
	private JCheckBox checkBox_1;
	private JCheckBox checkBox_2;
	private JCheckBox checkBox_3;
	private JCheckBox checkBox_4;
	private JCheckBox checkBox_5;
	private JComboBox comboBox_1;
	private JComboBox comboBox_2;
	private JRadioButton rdbtnNewRadioButton;
	private JRadioButton radioButton_3;
	private JRadioButton radioButton_4;
	private JScrollPane scrollPane_1;
	private JTextArea textArea;
	private JButton btnNewButton_1;
	private JLabel lblNewLabel_1;
	private JLabel lblNewLabel_2;
	private JLabel lblNewLabel_3;
	private JLabel lblNewLabel_4;
	private JLabel label_3;
	private JLabel label_4;
	private final ButtonGroup buttonGroup_1 = new ButtonGroup();
	private JLabel label_5;
	private JLabel label_6;
	private JLabel label_7;
	private JLabel label_8;
	private JLabel label_9;
	private JLabel lblNewLabel_5;
	private JLabel mid_v;
	private JLabel irum_v;
	private JLabel birth_v;
	private JLabel tel_v;
	private JSeparator separator;
	private JButton btn_save;
	private JButton btn_modi;
	private JButton btn_del;
	private final ButtonGroup buttonGroup_2 = new ButtonGroup();
	private JButton btnNewButton_2;
	private JButton btnNewButton_3;
	private JComboBox comboBox_3;
	
	
	int oristamp=0;
	String path = "";
	String allpath ="";
//	String savedir ="F://java work space//FinalProjectWeb//WebContent//imgs//";
	String savedir = "C://Users//이종기//Desktop//HTA//FinalWorkspace//FinalProjectWeb//WebContent//imgs//";
	int origrade = 0;
	String[] category = new String[] { "전체", "디자이너", "회원" };
	String selectcategory = "";
	private JButton btnNewButton_4;
	private JButton button;
	private JButton btnNewButton_5;
	private JLabel testla;
	private JTextField addr_v;
	private JTextField stamp;

	/**
	 * Create the panel.
	 */
	public MemberPanel(JPanel contentPane) {
		setBackground(Color.WHITE);
		this.contentPane = contentPane;
		setLayout(null);
		add(getTextField());
		add(getBtnNewButton());
		add(getScrollPane());
		add(getLblNewLabel());
		add(getLabel());
		add(getLabel_1());
		add(getLabel_2());
		add(getRadioButton());
		add(getRadioButton_1());
		add(getRadioButton_2());
		add(getChckbxNewCheckBox());
		add(getCheckBox());
		add(getCheckBox_1());
		add(getCheckBox_2());
		add(getCheckBox_3());
		add(getCheckBox_4());
		add(getCheckBox_5());
		add(getComboBox_1());
		add(getComboBox_2());
		add(getRdbtnNewRadioButton());
		add(getRadioButton_3());
		add(getRadioButton_4());
		add(getScrollPane_1());
		add(getBtnNewButton_1());
		add(getLblNewLabel_1());
		add(getLblNewLabel_2());
		add(getLblNewLabel_3());
		add(getLblNewLabel_4());
		add(getLabel_3());
		add(getLabel_4());
		add(getLabel_5());
		add(getLabel_6());
		add(getLabel_7());
		add(getLabel_8());
		add(getLabel_9());
		add(getLblNewLabel_5());
		add(getMid_v());
		add(getIrum_v());
		add(getBirth_v());
		add(getTel_v());
		add(getSeparator());
		add(getBtn_save());
		add(getBtn_modi());
		add(getBtn_del());
		add(getBtnNewButton_2());
		add(getBtnNewButton_3());
		add(getComboBox_3());
		add(getBtnNewButton_4());
		add(getButton());
		add(getBtnNewButton_5());
		add(getTestla());
		add(getAddr_v());
		add(getStamp());
	}

	private JTextField getTextField() {
		if (textField == null) {
			textField = new JTextField();
			textField.setBounds(120, 24, 187, 21);
			textField.setColumns(10);
		}
		return textField;
	}

	private JButton getBtnNewButton() {
		if (btnNewButton == null) {
			btnNewButton = new JButton("검색");
			btnNewButton.setBackground(Color.WHITE);
			btnNewButton.setFont(new Font("Gulim", Font.PLAIN, 12));
			btnNewButton.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					select();
				}
			});
			btnNewButton.setBounds(319, 23, 97, 23);
		}
		return btnNewButton;
	}

	private JScrollPane getScrollPane() {
		if (scrollPane == null) {
			scrollPane = new JScrollPane();
			scrollPane.setBounds(12, 65, 500, 304);
			scrollPane.setViewportView(getTable());
		}
		return scrollPane;
	}

	private JTable getTable() {
		if (table == null) {
			table = new JTable();
			table.addMouseListener(new MouseAdapter() {
				@Override
				public void mouseReleased(MouseEvent arg0) {
					int r = table.getSelectedRow(); // 선택된 행 번호

					mid_v.setText((String) table.getValueAt(r, 0));
					irum_v.setText((String) table.getValueAt(r, 1));
					birth_v.setText((String) table.getValueAt(r, 2));
					tel_v.setText((String) table.getValueAt(r, 3));
					addr_v.setText((String) table.getValueAt(r, 4));
					String grade = (String) table.getValueAt(r, 5);
					stamp.setText((int) table.getValueAt(r, 6)+"");
					oristamp = (int) table.getValueAt(r, 6);
					origrade = Integer.parseInt(grade);
					radioButton.setEnabled(true);
					radioButton_1.setEnabled(true);
					radioButton_2.setEnabled(true);
					
					btnNewButton_5.setEnabled(true);
					switch (grade) {
					case "1":
						radioButton.setSelected(true);
						disabledesign();
						cleandesign();
						cleanbtn();
						btnNewButton_3.setEnabled(false);
						break;
					case "2":
						radioButton_1.setSelected(true);
						designer((String) table.getValueAt(r, 0));
						btnNewButton_3.setEnabled(true);
						break;
					case "3":
						radioButton_2.setSelected(true);
						disabledesign();
						cleandesign();
						cleanbtn();
						btnNewButton_3.setEnabled(false);
						break;

					}

				}
			});
		}
		return table;
	}

	public void select() {
		Vector<String> v = new Vector<String>();
		v.add("ID");
		v.add("이름");
		v.add("생년월일");
		v.add("연락처");
		v.add("주소");
		v.add("회원등급");
		v.add("스템프");

		DefaultTableModel tmodel = new DefaultTableModel(v, 0);

		dto = new ManageDTO();
		ArrayList<MemberVo> al = new ArrayList<MemberVo>();
		al = dto.selectmember(selectcategory, textField.getText());

		for (MemberVo vo : al) {
			Vector vec = new Vector();
			vec.add(vo.getMid());
			vec.add(vo.getIrum());
			vec.add(vo.getBirth());
			vec.add(vo.getTel());
			vec.add(vo.getAddress());
			vec.add(vo.getGrade());
			vec.add(vo.getStamp());
			tmodel.addRow(vec);
		}

		table.setModel(tmodel);

	}

	public void designer(String mid) {
		btn_modi.setEnabled(true);
		btn_del.setEnabled(true);
		btn_save.setEnabled(false);
		enabledesign();
		dto = new ManageDTO();
		DesignerVo v = dto.checkdesigner(mid);
		if (v != null) {
			String[] day = v.getWorkday().split(",");
			dischek();
			for (int a = 0; a < day.length; a++) {
				switch (day[a]) {
				case "월":
					chckbxNewCheckBox.setSelected(true);
					break;
				case "화":
					checkBox.setSelected(true);
					break;
				case "수":
					checkBox_1.setSelected(true);
					break;
				case "목":
					checkBox_2.setSelected(true);
					break;
				case "금":
					checkBox_3.setSelected(true);
					break;
				case "토":
					checkBox_4.setSelected(true);
					break;
				case "일":
					checkBox_5.setSelected(true);
					break;
				}
			}
			String[] time = v.getWorktime().split("-");
			int stime = Integer.parseInt(time[0]);
			int etime = Integer.parseInt(time[1]);
			int sindex = 0;
			int eindex = 0;
			if (stime > 9) {
				sindex = stime - 9;
			}
			if (etime > 9) {
				eindex = etime - 9;
			}
			comboBox_1.setSelectedIndex(sindex);
			comboBox_2.setSelectedIndex(eindex);
			switch (v.getGrade()) {
			case "원장":
				rdbtnNewRadioButton.setSelected(true);
				break;
			case "실장":
				radioButton_3.setSelected(true);
				break;
			case "디자이너":
				radioButton_4.setSelected(true);
				break;
			}
			textArea.setText(v.getInfo());
			lblNewLabel_1.setText(v.getAttfile());

		} else {

		}

	}

	public void cleanbtn() {
		btn_modi.setEnabled(false);
		btn_del.setEnabled(false);
		btn_save.setEnabled(false);

	}

	public void cleandesign() {
		dischek();
		textArea.setText("");
		lblNewLabel_1.setText("");
		comboBox_1.setSelectedIndex(0);
		comboBox_2.setSelectedIndex(0);
		radioButton_4.setSelected(true);

	}

	public void dischek() {
		checkBox.setSelected(false);
		checkBox_1.setSelected(false);
		checkBox_2.setSelected(false);
		checkBox_3.setSelected(false);
		checkBox_4.setSelected(false);
		checkBox_5.setSelected(false);
		chckbxNewCheckBox.setSelected(false);

	}

	public void enabledesign() {
		checkBox.setEnabled(true);
		checkBox_1.setEnabled(true);
		checkBox_2.setEnabled(true);
		checkBox_3.setEnabled(true);
		checkBox_4.setEnabled(true);
		checkBox_5.setEnabled(true);
		chckbxNewCheckBox.setEnabled(true);
		comboBox_1.setEnabled(true);
		comboBox_2.setEnabled(true);
		rdbtnNewRadioButton.setEnabled(true);
		radioButton_3.setEnabled(true);
		radioButton_4.setEnabled(true);
		btnNewButton_1.setEnabled(true);
		textArea.setEnabled(true);

	}

	public void disabledesign() {
		checkBox.setEnabled(false);
		checkBox_1.setEnabled(false);
		checkBox_2.setEnabled(false);
		checkBox_3.setEnabled(false);
		checkBox_4.setEnabled(false);
		checkBox_5.setEnabled(false);
		chckbxNewCheckBox.setEnabled(false);
		comboBox_1.setEnabled(false);
		comboBox_2.setEnabled(false);
		rdbtnNewRadioButton.setEnabled(false);
		radioButton_3.setEnabled(false);
		radioButton_4.setEnabled(false);
		btnNewButton_1.setEnabled(false);
		textArea.setEnabled(false);

	}

	private JLabel getLblNewLabel() {
		if (lblNewLabel == null) {
			lblNewLabel = new JLabel("ID : ");
			lblNewLabel.setFont(new Font("Gulim", Font.PLAIN, 12));
			lblNewLabel.setHorizontalAlignment(SwingConstants.RIGHT);
			lblNewLabel.setBounds(518, 94, 73, 15);
		}
		return lblNewLabel;
	}

	private JLabel getLabel() {
		if (label == null) {
			label = new JLabel("이름 : ");
			label.setFont(new Font("Gulim", Font.PLAIN, 12));
			label.setHorizontalAlignment(SwingConstants.RIGHT);
			label.setBounds(518, 119, 73, 15);
		}
		return label;
	}

	private JLabel getLabel_1() {
		if (label_1 == null) {
			label_1 = new JLabel("회원등급");
			label_1.setFont(new Font("Gulim", Font.PLAIN, 12));
			label_1.setBounds(539, 218, 63, 15);
		}
		return label_1;
	}

	private JLabel getLabel_2() {
		if (label_2 == null) {
			label_2 = new JLabel("스템프");
			label_2.setFont(new Font("Gulim", Font.PLAIN, 12));
			label_2.setBounds(532, 296, 45, 15);
		}
		return label_2;
	}

	private JRadioButton getRadioButton() {
		if (radioButton == null) {
			radioButton = new JRadioButton("관리자");
			radioButton.setBackground(Color.WHITE);
			radioButton.setEnabled(false);
			radioButton.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					cleanbtn();
					disabledesign();
					if (origrade == 1) {
						btnNewButton_2.setEnabled(false);
					} else {
						btnNewButton_2.setEnabled(true);
					}
				}
			});
			radioButton.setFont(new Font("Gulim", Font.PLAIN, 12));
			buttonGroup.add(radioButton);
			radioButton.setBounds(595, 215, 88, 21);
		}
		return radioButton;
	}

	private JRadioButton getRadioButton_1() {
		if (radioButton_1 == null) {
			radioButton_1 = new JRadioButton("디자이너");
			radioButton_1.setBackground(Color.WHITE);
			radioButton_1.setEnabled(false);
			radioButton_1.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					enabledesign();
					if (origrade == 2) {
						btnNewButton_2.setEnabled(false);
					} else {
						btnNewButton_2.setEnabled(true);
					}
					if (textArea.getText().equals("")) {
						btn_save.setEnabled(true);
						btn_modi.setEnabled(false);
						btn_del.setEnabled(false);
					} else {
						btn_modi.setEnabled(true);
						btn_del.setEnabled(true);
						btn_save.setEnabled(false);
					}
				}
			});
			radioButton_1.setFont(new Font("Gulim", Font.PLAIN, 12));
			buttonGroup.add(radioButton_1);
			radioButton_1.setBounds(595, 237, 88, 21);
		}
		return radioButton_1;
	}

	private JRadioButton getRadioButton_2() {
		if (radioButton_2 == null) {
			radioButton_2 = new JRadioButton("회원");
			radioButton_2.setBackground(Color.WHITE);
			radioButton_2.setEnabled(false);
			radioButton_2.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					disabledesign();
					cleanbtn();
					if (origrade == 3) {
						btnNewButton_2.setEnabled(false);
					} else {
						btnNewButton_2.setEnabled(true);
					}
				}
			});
			radioButton_2.setFont(new Font("Gulim", Font.PLAIN, 12));
			buttonGroup.add(radioButton_2);
			radioButton_2.setBounds(595, 258, 88, 21);
		}
		return radioButton_2;
	}

	private JCheckBox getChckbxNewCheckBox() {
		if (chckbxNewCheckBox == null) {
			chckbxNewCheckBox = new JCheckBox("월");
			chckbxNewCheckBox.setBackground(Color.WHITE);
			chckbxNewCheckBox.setEnabled(false);
			chckbxNewCheckBox.setFont(new Font("굴림", Font.PLAIN, 11));
			chckbxNewCheckBox.setBounds(12, 439, 37, 23);
		}
		return chckbxNewCheckBox;
	}

	private JCheckBox getCheckBox() {
		if (checkBox == null) {
			checkBox = new JCheckBox("화");
			checkBox.setBackground(Color.WHITE);
			checkBox.setEnabled(false);
			checkBox.setFont(new Font("굴림", Font.PLAIN, 11));
			checkBox.setBounds(55, 439, 37, 23);
		}
		return checkBox;
	}

	private JCheckBox getCheckBox_1() {
		if (checkBox_1 == null) {
			checkBox_1 = new JCheckBox("수");
			checkBox_1.setBackground(Color.WHITE);
			checkBox_1.setEnabled(false);
			checkBox_1.setFont(new Font("굴림", Font.PLAIN, 11));
			checkBox_1.setBounds(102, 439, 37, 23);
		}
		return checkBox_1;
	}

	private JCheckBox getCheckBox_2() {
		if (checkBox_2 == null) {
			checkBox_2 = new JCheckBox("목");
			checkBox_2.setBackground(Color.WHITE);
			checkBox_2.setEnabled(false);
			checkBox_2.setFont(new Font("굴림", Font.PLAIN, 11));
			checkBox_2.setBounds(143, 439, 37, 23);
		}
		return checkBox_2;
	}

	private JCheckBox getCheckBox_3() {
		if (checkBox_3 == null) {
			checkBox_3 = new JCheckBox("금");
			checkBox_3.setBackground(Color.WHITE);
			checkBox_3.setEnabled(false);
			checkBox_3.setFont(new Font("굴림", Font.PLAIN, 11));
			checkBox_3.setBounds(32, 463, 37, 23);
		}
		return checkBox_3;
	}

	private JCheckBox getCheckBox_4() {
		if (checkBox_4 == null) {
			checkBox_4 = new JCheckBox("토");
			checkBox_4.setBackground(Color.WHITE);
			checkBox_4.setEnabled(false);
			checkBox_4.setFont(new Font("굴림", Font.PLAIN, 11));
			checkBox_4.setForeground(Color.BLUE);
			checkBox_4.setBounds(77, 463, 37, 23);
		}
		return checkBox_4;
	}

	private JCheckBox getCheckBox_5() {
		if (checkBox_5 == null) {
			checkBox_5 = new JCheckBox("일");
			checkBox_5.setBackground(Color.WHITE);
			checkBox_5.setEnabled(false);
			checkBox_5.setFont(new Font("굴림", Font.PLAIN, 11));
			checkBox_5.setForeground(Color.RED);
			checkBox_5.setBounds(120, 464, 37, 23);
		}
		return checkBox_5;
	}

	private JComboBox getComboBox_1() {
		if (comboBox_1 == null) {
			comboBox_1 = new JComboBox();
			comboBox_1.setBackground(Color.WHITE);
			comboBox_1.setEnabled(false);
			comboBox_1.setModel(new DefaultComboBoxModel(new String[] { "9",
					"10", "11", "12", "13", "14", "15", "16", "17", "18", "19",
					"20", "21", "22" }));
			comboBox_1.setBounds(12, 517, 57, 31);
		}
		return comboBox_1;
	}

	private JComboBox getComboBox_2() {
		if (comboBox_2 == null) {
			comboBox_2 = new JComboBox();
			comboBox_2.setBackground(Color.WHITE);
			comboBox_2.setEnabled(false);
			comboBox_2.setModel(new DefaultComboBoxModel(new String[] { "9",
					"10", "11", "12", "13", "14", "15", "16", "17", "18", "19",
					"20", "21", "22" }));
			comboBox_2.setBounds(100, 517, 57, 31);
		}
		return comboBox_2;
	}

	private JRadioButton getRdbtnNewRadioButton() {
		if (rdbtnNewRadioButton == null) {
			rdbtnNewRadioButton = new JRadioButton("원장");
			rdbtnNewRadioButton.setBackground(Color.WHITE);
			rdbtnNewRadioButton.setEnabled(false);
			rdbtnNewRadioButton.setFont(new Font("굴림", Font.PLAIN, 11));
			buttonGroup_1.add(rdbtnNewRadioButton);
			rdbtnNewRadioButton.setBounds(226, 439, 49, 21);
		}
		return rdbtnNewRadioButton;
	}

	private JRadioButton getRadioButton_3() {
		if (radioButton_3 == null) {
			radioButton_3 = new JRadioButton("실장");
			radioButton_3.setBackground(Color.WHITE);
			radioButton_3.setEnabled(false);
			radioButton_3.setFont(new Font("굴림", Font.PLAIN, 11));
			buttonGroup_1.add(radioButton_3);
			radioButton_3.setBounds(283, 439, 49, 21);
		}
		return radioButton_3;
	}

	private JRadioButton getRadioButton_4() {
		if (radioButton_4 == null) {
			radioButton_4 = new JRadioButton("디자이너");
			radioButton_4.setBackground(Color.WHITE);
			radioButton_4.setEnabled(false);
			radioButton_4.setFont(new Font("굴림", Font.PLAIN, 11));
			buttonGroup_1.add(radioButton_4);
			radioButton_4.setBounds(336, 439, 80, 21);
		}
		return radioButton_4;
	}

	private JScrollPane getScrollPane_1() {
		if (scrollPane_1 == null) {
			scrollPane_1 = new JScrollPane();
			scrollPane_1.setBounds(434, 438, 194, 110);
			scrollPane_1.setViewportView(getTextArea());
		}
		return scrollPane_1;
	}

	private JTextArea getTextArea() {
		if (textArea == null) {
			textArea = new JTextArea();
			textArea.setEnabled(false);
		}
		return textArea;
	}

	private JButton getBtnNewButton_1() {
		if (btnNewButton_1 == null) {
			btnNewButton_1 = new JButton("파일선택");
			btnNewButton_1.setBackground(Color.WHITE);
			btnNewButton_1.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					
					
					JFileChooser jfc = new JFileChooser();
					jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
					int yn = jfc.showOpenDialog(MemberPanel.this);
					if (yn == JFileChooser.APPROVE_OPTION) {
						path = jfc.getSelectedFile().getName();
						allpath = jfc.getSelectedFile().getAbsolutePath();
					String ff[] = path.split("\\.");

					if (ff[1].equals("jpg") || ff[1].equals("png")
							|| ff[1].equals("jpeg") || ff[1].equals("gif") || ff[1].equals("JPG") ) {
						lblNewLabel_1.setText(path);
						testla.setText(allpath);
					} else {
						JOptionPane.showMessageDialog(MemberPanel.this,
								"jpg,png,gif만 선택할수있습니다.");
					}
					}else if(yn == JFileChooser.CANCEL_OPTION){
						path="";
						allpath="";
					}
				}
			});
			btnNewButton_1.setEnabled(false);
			btnNewButton_1.setFont(new Font("Gulim", Font.PLAIN, 12));
			btnNewButton_1.setBounds(227, 521, 97, 23);
		}
		return btnNewButton_1;
	}

	private JLabel getLblNewLabel_1() {
		if (lblNewLabel_1 == null) {
			lblNewLabel_1 = new JLabel("");
			lblNewLabel_1.setBounds(324, 521, 98, 21);
		}
		return lblNewLabel_1;
	}

	private JLabel getLblNewLabel_2() {
		if (lblNewLabel_2 == null) {
			lblNewLabel_2 = new JLabel("◆ 디자이너 등록");
			lblNewLabel_2.setFont(new Font("Gulim", Font.PLAIN, 12));
			lblNewLabel_2.setBounds(12, 390, 102, 21);
		}
		return lblNewLabel_2;
	}

	private JLabel getLblNewLabel_3() {
		if (lblNewLabel_3 == null) {
			lblNewLabel_3 = new JLabel("근무 요일");
			lblNewLabel_3.setFont(new Font("Gulim", Font.PLAIN, 12));
			lblNewLabel_3.setBounds(12, 421, 57, 15);
		}
		return lblNewLabel_3;
	}

	private JLabel getLblNewLabel_4() {
		if (lblNewLabel_4 == null) {
			lblNewLabel_4 = new JLabel("근무 시간");
			lblNewLabel_4.setFont(new Font("Gulim", Font.PLAIN, 12));
			lblNewLabel_4.setBounds(12, 492, 57, 15);
		}
		return lblNewLabel_4;
	}

	private JLabel getLabel_3() {
		if (label_3 == null) {
			label_3 = new JLabel("~");
			label_3.setBounds(77, 517, 15, 15);
		}
		return label_3;
	}

	private JLabel getLabel_4() {
		if (label_4 == null) {
			label_4 = new JLabel("직급");
			label_4.setFont(new Font("Gulim", Font.PLAIN, 12));
			label_4.setBounds(230, 421, 57, 15);
		}
		return label_4;
	}

	private JLabel getLabel_5() {
		if (label_5 == null) {
			label_5 = new JLabel("사진");
			label_5.setFont(new Font("Gulim", Font.PLAIN, 12));
			label_5.setBounds(226, 486, 57, 15);
		}
		return label_5;
	}

	private JLabel getLabel_6() {
		if (label_6 == null) {
			label_6 = new JLabel("경력 사항");
			label_6.setFont(new Font("Gulim", Font.PLAIN, 12));
			label_6.setBounds(434, 413, 57, 15);
		}
		return label_6;
	}

	private JLabel getLabel_7() {
		if (label_7 == null) {
			label_7 = new JLabel("생년월일 : ");
			label_7.setFont(new Font("Gulim", Font.PLAIN, 12));
			label_7.setHorizontalAlignment(SwingConstants.RIGHT);
			label_7.setBounds(518, 144, 73, 15);
		}
		return label_7;
	}

	private JLabel getLabel_8() {
		if (label_8 == null) {
			label_8 = new JLabel("연락처 : ");
			label_8.setFont(new Font("Gulim", Font.PLAIN, 12));
			label_8.setHorizontalAlignment(SwingConstants.RIGHT);
			label_8.setBounds(518, 169, 73, 15);
		}
		return label_8;
	}

	private JLabel getLabel_9() {
		if (label_9 == null) {
			label_9 = new JLabel("주소 : ");
			label_9.setFont(new Font("Gulim", Font.PLAIN, 12));
			label_9.setHorizontalAlignment(SwingConstants.RIGHT);
			label_9.setBounds(518, 194, 73, 15);
		}
		return label_9;
	}

	private JLabel getLblNewLabel_5() {
		if (lblNewLabel_5 == null) {
			lblNewLabel_5 = new JLabel("◆ 회원정보");
			lblNewLabel_5.setFont(new Font("Gulim", Font.PLAIN, 12));
			lblNewLabel_5.setBounds(518, 66, 73, 15);
		}
		return lblNewLabel_5;
	}

	private JLabel getMid_v() {
		if (mid_v == null) {
			mid_v = new JLabel("");
			mid_v.setFont(new Font("Gulim", Font.PLAIN, 12));
			mid_v.setBounds(596, 95, 107, 15);
		}
		return mid_v;
	}

	private JLabel getIrum_v() {
		if (irum_v == null) {
			irum_v = new JLabel("");
			irum_v.setFont(new Font("Gulim", Font.PLAIN, 12));
			irum_v.setBounds(596, 120, 107, 15);
		}
		return irum_v;
	}

	private JLabel getBirth_v() {
		if (birth_v == null) {
			birth_v = new JLabel("");
			birth_v.setFont(new Font("Gulim", Font.PLAIN, 12));
			birth_v.setBounds(596, 145, 107, 15);
		}
		return birth_v;
	}

	private JLabel getTel_v() {
		if (tel_v == null) {
			tel_v = new JLabel("");
			tel_v.setFont(new Font("Gulim", Font.PLAIN, 12));
			tel_v.setBounds(596, 170, 107, 15);
		}
		return tel_v;
	}

	private JSeparator getSeparator() {
		if (separator == null) {
			separator = new JSeparator();
			separator.setBounds(524, 371, 243, 16);
		}
		return separator;
	}

	private JButton getBtn_save() {
		if (btn_save == null) {
			btn_save = new JButton("저장");
			btn_save.setBackground(Color.WHITE);
			btn_save.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					dto = new ManageDTO();
					DesignerVo v = new DesignerVo();
					v.setMid(mid_v.getText());
					ArrayList<String> day = new ArrayList<String>();
					if (chckbxNewCheckBox.isSelected()) {
						day.add("월");
					}
					if (checkBox.isSelected()) {
						day.add("화");
					}
					if (checkBox_1.isSelected()) {
						day.add("수");
					}
					if (checkBox_2.isSelected()) {
						day.add("목");
					}
					if (checkBox_3.isSelected()) {
						day.add("금");
					}
					if (checkBox_4.isSelected()) {
						day.add("토");
					}
					if (checkBox_5.isSelected()) {
						day.add("일");
					}
					if (day.size() == 0) {
						JOptionPane.showMessageDialog(MemberPanel.this,
								"근무요일을 선택 하세요");
					} else {
						String wd = day.get(0);
						for (int a = 1; a < day.size(); a++) {

							wd += "," + day.get(a);

						}
						v.setWorkday(wd);
					}
					String wt = (String) comboBox_1.getSelectedItem() + "-"
							+ (String) comboBox_2.getSelectedItem();
					v.setWorktime(wt);
					String grade = "";
					if (rdbtnNewRadioButton.isSelected()) {
						grade = "원장";
					} else if (radioButton_3.isSelected()) {
						grade = "실장";
					} else if (radioButton_4.isSelected()) {
						grade = "디자이너";
					}
					v.setGrade(grade);
					v.setInfo(textArea.getText());
					v.setAttfile(lblNewLabel_1.getText());
					ManageDTO dto2 = new ManageDTO();
					if (dto2.updatememberdesigner(mid_v.getText(), 2, Integer.parseInt(stamp.getText()) )) {

						if (dto.registdesigner(v)) {
							JOptionPane.showMessageDialog(MemberPanel.this,
									"등록 완료");
							select();
							if(!(lblNewLabel_1.getText().equals(""))){
								filein(allpath,savedir+path);
								}
						} else {
							JOptionPane.showMessageDialog(MemberPanel.this,
									"등록 오류");
						}
					} else {
						JOptionPane.showMessageDialog(MemberPanel.this,
								"등록 오류(member수정 오류)");
					}
					
				}
			});
			btn_save.setEnabled(false);
			btn_save.setFont(new Font("Gulim", Font.PLAIN, 12));
			btn_save.setBounds(640, 437, 97, 23);
		}
		return btn_save;
	}

	private JButton getBtn_modi() {
		if (btn_modi == null) {
			btn_modi = new JButton("수정");
			btn_modi.setBackground(Color.WHITE);
			btn_modi.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					dto = new ManageDTO();
					DesignerVo v = new DesignerVo();
					v.setMid(mid_v.getText());
					ArrayList<String> day = new ArrayList<String>();
					if (chckbxNewCheckBox.isSelected()) {
						day.add("월");
					}
					if (checkBox.isSelected()) {
						day.add("화");
					}
					if (checkBox_1.isSelected()) {
						day.add("수");
					}
					if (checkBox_2.isSelected()) {
						day.add("목");
					}
					if (checkBox_3.isSelected()) {
						day.add("금");
					}
					if (checkBox_4.isSelected()) {
						day.add("토");
					}
					if (checkBox_5.isSelected()) {
						day.add("일");
					}
					if (day.size() == 0) {
						JOptionPane.showMessageDialog(MemberPanel.this,
								"근무요일을 선택 하세요");
					} else {
						String wd = day.get(0);
						for (int a = 1; a < day.size(); a++) {

							wd += "," + day.get(a);

						}
						v.setWorkday(wd);
					}
					String wt = (String) comboBox_1.getSelectedItem() + "-"
							+ (String) comboBox_2.getSelectedItem();
					v.setWorktime(wt);
					String grade = "";
					if (rdbtnNewRadioButton.isSelected()) {
						grade = "원장";
					} else if (radioButton_3.isSelected()) {
						grade = "실장";
					} else if (radioButton_4.isSelected()) {
						grade = "디자이너";
					}
					v.setGrade(grade);
					v.setInfo(textArea.getText());
					v.setAttfile(lblNewLabel_1.getText());
					ManageDTO dto2 = new ManageDTO();
					
					

					if (dto.updatedesigner(v)) {
						JOptionPane
								.showMessageDialog(MemberPanel.this, "수정 완료");
						if(!(lblNewLabel_1.getText().equals(""))){
							filein(allpath,savedir+path);
							}
						select();
					} else {
						JOptionPane
								.showMessageDialog(MemberPanel.this, "수정 오류");
					}
					
				}

			});
			btn_modi.setEnabled(false);
			btn_modi.setFont(new Font("Gulim", Font.PLAIN, 12));
			btn_modi.setBounds(640, 462, 97, 23);
		}
		return btn_modi;
	}

	private JButton getBtn_del() {
		if (btn_del == null) {
			btn_del = new JButton("삭제");
			btn_del.setBackground(Color.WHITE);
			btn_del.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					dto = new ManageDTO();
					ManageDTO dto2 = new ManageDTO();
					if (dto2.updatememberdesigner(mid_v.getText(), 3 , Integer.parseInt(stamp.getText()))) {

						if (dto.deletedesigner(mid_v.getText())) {
							JOptionPane.showMessageDialog(MemberPanel.this,
									"삭제 완료");
							select();
						} else {
							JOptionPane.showMessageDialog(MemberPanel.this,
									"삭제 오류");
						}
					} else {
						JOptionPane.showMessageDialog(MemberPanel.this,
								"삭제 오류(member 오류)");
					}

				}
			});
			btn_del.setEnabled(false);
			btn_del.setFont(new Font("Gulim", Font.PLAIN, 12));
			btn_del.setBounds(640, 488, 97, 23);
		}
		return btn_del;
	}

	private JButton getBtnNewButton_2() {
		if (btnNewButton_2 == null) {
			btnNewButton_2 = new JButton("수  정");
			btnNewButton_2.setBackground(Color.WHITE);
			btnNewButton_2.setEnabled(false);
			btnNewButton_2.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {

					int grade = 0;
					if (radioButton.isSelected()) {
						grade = 1;
					} else if (radioButton_1.isSelected()) {
						grade = 2;
					} else if (radioButton_2.isSelected()) {
						grade = 3;
					}

					dto = new ManageDTO();
					if (grade == 1) {
						JOptionPane.showMessageDialog(MemberPanel.this,
								"관리자 등록 불가");
					} else {

						if (dto.updatememberdesigner(mid_v.getText(), grade , Integer.parseInt(stamp.getText()))) {
							JOptionPane.showMessageDialog(MemberPanel.this,
									"회원 등급 수정 완료");
							select();
						} else {
							JOptionPane.showMessageDialog(MemberPanel.this,
									"수정 오류");
						}
					}

				}
			});
			btnNewButton_2.setFont(new Font("Gulim", Font.PLAIN, 12));
			btnNewButton_2.setBounds(628, 338, 97, 23);
		}
		return btnNewButton_2;
	}

	private JButton getBtnNewButton_3() {
		if (btnNewButton_3 == null) {
			btnNewButton_3 = new JButton("가격표설정");
			btnNewButton_3.setBackground(Color.WHITE);
			btnNewButton_3.setEnabled(false);
			btnNewButton_3.setFont(new Font("Gulim", Font.PLAIN, 12));
			btnNewButton_3.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {

					MemberVo vv = new MemberVo();
					vv.setMid(mid_v.getText());
					vv.setIrum(irum_v.getText());
					String grade = "";
					if (rdbtnNewRadioButton.isSelected()) {
						grade = "원장";
					} else if (radioButton_3.isSelected()) {
						grade = "실장";
					} else if (radioButton_4.isSelected()) {
						grade = "디자이너";
					}

					vv.setGrade(grade);

					contentPane.removeAll();
					contentPane.add(new DesignerEdit(contentPane, vv));
					contentPane.updateUI();

				}
			});
			btnNewButton_3.setBounds(639, 525, 97, 23);
		}
		return btnNewButton_3;
	}

	private JComboBox getComboBox_3() {
		if (comboBox_3 == null) {
			comboBox_3 = new JComboBox();
			comboBox_3.setBackground(Color.WHITE);
			comboBox_3.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {

					switch (comboBox_3.getSelectedIndex()) {
					case 0:
						selectcategory = "";
						break;
					case 1:
						selectcategory = "2";
						break;
					case 2:
						selectcategory = "3";
						break;

					}

				}
			});
			comboBox_3.setFont(new Font("Gulim", Font.PLAIN, 12));
			comboBox_3.setModel(new DefaultComboBoxModel(category));
			comboBox_3.setBounds(12, 23, 102, 21);
		}
		return comboBox_3;
	}

	private JButton getBtnNewButton_4() {
		if (btnNewButton_4 == null) {
			btnNewButton_4 = new JButton("-");
			btnNewButton_4.setBackground(Color.WHITE);
			btnNewButton_4.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					int ms = Integer.parseInt(stamp.getText());
					ms--;
					
					
					if(ms>=1){
					 stamp.setText(ms+"");
					 }else{
						 ms=0;
					 stamp.setText(ms+"");
					 }
					if(oristamp == ms){
						 btnNewButton_2.setEnabled(false);
					 }else{
						 btnNewButton_2.setEnabled(true);
					 } 
					
					
				}
			});
			btnNewButton_4.setFont(new Font("굴림", Font.PLAIN, 9));
			btnNewButton_4.setBounds(630, 307, 50, 23);
		}
		return btnNewButton_4;
	}

	private JButton getButton() {
		if (button == null) {
			button = new JButton("+");
			button.setBackground(Color.WHITE);
			button.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					 
					 int ps = Integer.parseInt(stamp.getText());
					 ps++;
					
					 
					 if(ps<11){
						 stamp.setText(ps+"");
					 }else{
						 ps=10;
						 stamp.setText(ps+"");
					  }
					 
					 if(oristamp == ps){
						 btnNewButton_2.setEnabled(false);
					 }else{
						 btnNewButton_2.setEnabled(true);
					 }
					 
				}
			});
			button.setFont(new Font("굴림", Font.PLAIN, 9));
			button.setBounds(630, 283, 50, 23);
		}
		return button;
	}

	private JButton getBtnNewButton_5() {
		if (btnNewButton_5 == null) {
			btnNewButton_5 = new JButton("탈퇴");
			btnNewButton_5.setBackground(Color.WHITE);
			btnNewButton_5.setEnabled(false);
			btnNewButton_5.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					dto = new ManageDTO();

					int a = JOptionPane.showConfirmDialog(MemberPanel.this,
							"회원정보를 삭제 하시겠습니까?", "회원 삭제",
							JOptionPane.YES_NO_CANCEL_OPTION,
							JOptionPane.INFORMATION_MESSAGE);

					if (a == JOptionPane.YES_OPTION) {
						
						if (dto.deletemember(mid_v.getText())) {
							JOptionPane	.showMessageDialog(MemberPanel.this, "삭제 완료");
							select();
							
						} else {
							JOptionPane.showMessageDialog(MemberPanel.this,	"삭제 오류");
						}
					}
				}
			});

			btnNewButton_5.setFont(new Font("Gulim", Font.PLAIN, 12));
			btnNewButton_5.setForeground(Color.RED);
			btnNewButton_5.setBounds(520, 338, 97, 23);
		}
		return btnNewButton_5;
	}
	public void filein(String fpn,String fn) {   // 첨부 파일 저장용 메소드

		FileInputStream fis = null;
		FileOutputStream fos = null;
		BufferedInputStream bis = null;
		BufferedOutputStream bos = null;
		try {
			fis = new FileInputStream(fpn);   //   경로 포함된 파일을 읽고
			bis = new BufferedInputStream(fis);
			fos = new FileOutputStream(fn);    //  기본 폴더(서버)에 씀
			bos = new BufferedOutputStream(fos);

			int br = 0;
			byte[] bf = new byte[1024];
			while ((br = bis.read(bf, 0, 1024)) != -1) {
				bos.write(bf, 0, br);
			}

		} catch (Exception e) {
		} finally {
			try {
				bos.close();
				bis.close();
				fos.close();
				fis.close();
			} catch (Exception e2) {
			}
		}
	}
	private JLabel getTestla() {
		if (testla == null) {
			testla = new JLabel("");
			testla.setBackground(Color.WHITE);
			testla.setBounds(434, 10, 360, 35);
		}
		return testla;
	}
	private JTextField getAddr_v() {
		if (addr_v == null) {
			addr_v = new JTextField();
			addr_v.setBackground(Color.WHITE);
			addr_v.setEditable(false);
			addr_v.setFont(new Font("Gulim", Font.PLAIN, 12));
			addr_v.setBounds(587, 191, 180, 21);
			addr_v.setColumns(10);
		}
		return addr_v;
	}
	private JTextField getStamp() {
		if (stamp == null) {
			stamp = new JTextField();
			stamp.setBackground(Color.WHITE);
			stamp.setFont(new Font("굴림", Font.PLAIN, 12));
			stamp.setEditable(false);
			stamp.setColumns(10);
			stamp.setBounds(573, 293, 49, 21);
		}
		return stamp;
	}
}
